package com.lovo.sheyingback.config;

import com.lovo.sheyingback.interceptor.JWTInterceptor;
import com.lovo.sheyingback.interceptor.RoleInterceptor;
import com.lovo.sheyingback.interceptor.SessionInterceptor;
import com.lovo.sheyingback.interceptor.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfiguation implements WebMvcConfigurer {
//    @Autowired
//    private SessionInterceptor sessionInterceptor;
    @Autowired
    private JWTInterceptor jwtInterceptor;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/upload/**").addResourceLocations("file:d:/server/upload/");

    }
    @Override
    public void addInterceptors(InterceptorRegistry registry){
        String [] addPathPatterns={"/**"};
        String [] excludePathPatterns={"/static/**"};
//        registry.addInterceptor(new UserInterceptor())
//                .addPathPatterns(addPathPatterns)
//                .excludePathPatterns(excludePathPatterns);
//        registry.addInterceptor(new RoleInterceptor())
//                .addPathPatterns(addPathPatterns)
//                .excludePathPatterns(excludePathPatterns);
//        registry.addInterceptor(sessionInterceptor)
//                .addPathPatterns(addPathPatterns)
//                .excludePathPatterns(excludePathPatterns);
//        registry.addInterceptor(jwtInterceptor)
//                .addPathPatterns(addPathPatterns)
//                .excludePathPatterns(excludePathPatterns);
    }
}
